﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThisIsELearning.Model;

namespace ThisIsELearning
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataManager ctx = new DataManager();

            //var company1 = (from p in ctx.PublishingCompanies
            //                where p.publishingCompanyId == 3
            //                select p).First();
            //Response.Write(company1.publishingCompanyId + " " + company1.companyName + " " + company1.companyContactNumber + " " + company1.companyAddress + "\n");

            PublishingCompany company1 = new PublishingCompany
            {
                publishingCompanyId = 6,
                companyName = "Publishing Company 1",
                companyAddress = "street add;add line 2;postcode city;state;country",
                companyContactNumber = "0323456789"
            };

            ctx.AddToPublishingCompanies(company1);
            ctx.SaveChanges();
            int a = 0;

            //Publisher publisher1 = new Publisher
            //{
            //    loginId = "publisher2",
            //    password = "123456",
            //    totalContentsPublished = 0,
            //    activationCode = "123456",
            //    isActivated = true,
            //    gender = "m",
            //    email = "publisher2@publisher.com",
            //    dateRegistered = DateTime.Now,
            //    PublishingCompany = company1,
            //    firstName = "publisher",
            //    lastName = "two",
            //    contactNumber = "0323456789",
            //    address = "street add;add line 2;postcode city;state;country"
            //};

            //ctx.AddToUsers(publisher1);

            //foreach (Publisher publisher in company1.Publishers)
            //    Response.Write(publisher.userId + " " + publisher.loginId + "\n");

            //var choice1 = (from a in ctx.AnswerChoices
            //              where a.answerId == 1
            //               select a).First() as SingleChoiceAnswer;
            //choice1.answerChoice += choice1.answerChoice + " modified";

            //var question1 = (from a in ctx.TopicQuestions
            //                 where a.topicQuestionId == 1
            //                 select a).First();

            //ctx.AnswerChoices.DeleteObject(question1.Answers.ToArray()[4]);

            //ctx.SaveChanges();

            //company1.Publishers.Add(publisher1);

            //Course course1 = new Course
            //{
            //    courseName = "Course One",
            //    courseDescription = "Course one description",
            //    grade = 6,
            //    Publisher = publisher1
            //};

            //CourseTopic topic1 = new CourseTopic
            //{
            //    courseTopicName = "Topic 1",
            //    courseTopicDescription = "Topic 1 description",
            //    Course = course1
            //};

            //LearningStyle style1 = new LearningStyle
            //{
            //    learningStyleName = "style one",
            //    learningStyleDescription = "style one desc"
            //};

            //TopicQuestion question1 = new TopicQuestion
            //{
            //    CourseTopic = topic1,
            //    difficultyLevel = 2,
            //    LearningStyle = style1
            //};

            //SingleChoiceAnswer answer1 = new SingleChoiceAnswer
            //{
            //    answerChoice = "Choice 1",
            //    answerType = 0,
            //    isAnswer = true,
            //};

            //SingleChoiceAnswer answer2 = new SingleChoiceAnswer
            //{
            //    answerChoice = "Choice 2",
            //    answerType = 0,
            //    isAnswer = false
            //};
            
            //SingleChoiceAnswer answer3 = new SingleChoiceAnswer
            //{
            //    answerChoice = "Choice 3",
            //    answerType = 0,
            //    isAnswer = false
            //};
            
            //SingleChoiceAnswer answer4 = new SingleChoiceAnswer
            //{
            //    answerChoice = "Choice 4",
            //    answerType = 0,
            //    isAnswer = false
            //};

            //SingleChoiceAnswer answer5 = new SingleChoiceAnswer
            //{
            //    answerChoice = "Choice 5",
            //    answerType = 0,
            //    isAnswer = false
            //};

            //question1.Answers.Add(answer1);
            //question1.Answers.Add(answer2);
            //question1.Answers.Add(answer3);
            //question1.Answers.Add(answer4);
            //question1.Answers.Add(answer5);

            //Tag tag1 = new Tag
            //{
            //    keyword = "course1",
            //    Course = course1
            //};

            //Tag tag2 = new Tag
            //{
            //    keyword = "topic1",
            //    CourseTopic = topic1
            //};

            //ctx.AddToPublishingCompanies(company1);
            //ctx.AddToUsers(publisher1);
            //ctx.AddToLearningStyles(style1);
            //ctx.AddToCourses(course1);
            //ctx.AddToCourseTopics(topic1);
            //ctx.AddToTopicQuestions(question1);
            //ctx.AddToAnswerChoices(answer1);
            //ctx.AddToAnswerChoices(answer2);
            //ctx.AddToAnswerChoices(answer3);
            //ctx.AddToAnswerChoices(answer4);
            //ctx.AddToAnswerChoices(answer5);
            //ctx.AddToTags(tag1);
            //ctx.AddToTags(tag2);

            //ctx.SaveChanges();
        }
    }
}